package com.spring.boot.core.utils;

import java.io.File;
import java.io.IOException;
import java.util.List;

import com.google.common.base.Charsets;
import com.google.common.io.Files;

public class PropertiesFile extends PropertiesMap {

	public PropertiesFile(String fileName) {
		File file = new File(fileName);
		List<String> lines = null;
		try {
			lines = Files.readLines(file, Charsets.UTF_8);
			for (String line : lines) {
				line = line.trim();
				if (line.length() == 0 || line.startsWith("#")) {
					continue;
				}
				int pos = line.indexOf("=");
				String key = pos >= 0 ? line.substring(0, pos).trim() : line;
				String value = pos >= 0 ? line.substring(pos + 1).trim() : "";
				properties.put(key, value);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
